import request from '@/utils/request'
import Qs from 'qs'

export default {
  /* 系统菜单树 */
  sysMenuTree: function(){
    return request({
      method: 'GET',
      url: '/sys/menu/menuTree'
    })
  },
	/* 系统菜单列表 */
	sysMenuList: function({ parentId, pageNo, pageSize}){
	  return request({
	    method: 'GET',
	    url: '/sys/menu/menuList',
	    params: {
				parentId: parentId,
	      pageNo: pageNo,
	      pageSize: pageSize
	    }
	  })
	},
	/* 系统菜单详情 */
	sysMenuDetail: function(id){
	  return request({
	    method: 'GET',
	    url: '/sys/menu/'+id
	  })
	},
	/* 新增系统菜单 */
	addMenu: function({parentId, name, sort, href, icon, showStatus, permission}){
	  return request({
	    method: 'POST',
	    url: '/sys/menu/addMenu',
	    data: Qs.stringify({
	      parentId: parentId,
				name: name,
				sort: sort,
				href: href,
				icon: icon,
				showStatus: showStatus,
				permission: permission
	    })
	  })
	},
	/* 更新系统菜单 */
	updateMenu: function({id, parentId, name, sort, href, icon, showStatus, permission}){
	  return request({
	    method: 'POST',
	    url: '/sys/menu/updateMenu',
	    data: Qs.stringify({
				id: id,
	      parentId: parentId,
	      name: name,
	      sort: sort,
	      href: href,
	      icon: icon,
	      showStatus: showStatus,
	      permission: permission
	    })
	  })
	},
}
